package com.punch.common.utils;

import com.punch.common.annotation.ExcelProperty;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * Excel工具类
 */
public class HulToolExcelUtil {

    /**
     * 获取excel头
     *
     * @param aClass 传入的类
     * @return Map<String, String>
     */
    public static Map<String, String> createExcelHeader(Class<?> aClass) {
        Map<String, String> headerAlias = new HashMap<>();
        Field[] declaredFields = aClass.getDeclaredFields();
        for (Field field : declaredFields) {
            ExcelProperty annotation = field.getAnnotation(ExcelProperty.class);
            headerAlias.put(annotation.value(), field.getName());
        }
        return headerAlias;
    }

}
